import java.util.Scanner;

public class Reverse3 {
    public static void main(String[] args) {
        //3次翻转实现数组右移
        //simple: 1 2 3 4 5->3 4 5 1 2  空间复杂度O(1)
        Scanner cin=new Scanner(System.in);
        while (cin.hasNext()){
            int n=cin.nextInt();
            int k=cin.nextInt();
            if(n==0)    return;
            int[] nums=new int[n];
            for(int i=0;i<n;i++){
                nums[i]=cin.nextInt();
            }
            rotate(nums,k);
            for(int i=0;i<n;i++){
                if(i!=0) System.out.print(" ");
                System.out.print(nums[i]);
            }
            System.out.println();
        }
    }
    public static void rotate(int nums[],int k){
        k=k%nums.length;
        reverse(nums,0,nums.length-1);
        reverse(nums,0,k-1);
        reverse(nums,k,nums.length-1);
    }
    private static void reverse(int nums[],int start,int end){
        for(int i=start, j=end;i<j;i++,j--){
            nums[j]^=nums[i];
            nums[i]^=nums[j];
            nums[j]^=nums[i];
        }
    }
}